﻿@{
    ViewBag.Title = "Error";
}

<div id="Wrapper2">
    <div id="content_header">
        <div id="headerimage">
        </div>
        <div id="theheader">@ViewBag.Header</div>
    </div>
    <!-- Left Column begins here -->
    <aside id="sidebar-wrapper">
        <nav class="sidebar">
            <!-- CONTENT GOES HERE -->
            <div>
                An error occurred and it has been logged. If the error persists, please contact the developers for assistance.
                <br /><br />
                Press the browser's back button to return to the last page before the error occurred.
                <br />
                @if (ViewBag.errorCode != null)
                {
                <p>The ErrorID for this error is @ViewBag.errorCode</p>
                }
            </div>
            <p>
                @Html.ActionLink("Return to Dashboard", "Index")
            </p>
        </nav>
    </aside>
    <!-- Right column begins here -->
    <article id="contents">
        
    </article>
    <!-- Right column ends here -->
</div>
<!-- Div wrapper2 ends here -->

<script type = "text/javascript">
    $(function () {
        var date = $("#taskDueDate").val();
        var month = parseInt(date.substr(0, date.indexOf('/')));
        var day = parseInt(date.substr(date.indexOf('/') + 1, date.lastIndexOf('/')));
        var year = parseInt(date.substr(date.lastIndexOf('/') + 1, 4));

        $(".datepicker").datepicker({ minDate: new Date(year, month - 1, day) });
    });

    $("#editForm").submit(function () {

        var button = $("input[type=image][clicked=true]").val();

        if (button == "Save") {
            //Determine if a taskName has been entered

            if ($("#taskName").val() == "") {
                $("#submitEdit").attr('clicked', 'false');
                $("#taskNameError").attr('style', 'color:red; visibility:visible;');
                $("#formError").attr('style', 'color:red; visibility:visible;');
                return false;
            }
            else {
                $("#taskNameError").attr('style', 'color:red; visibility:hidden;');
                $("#formError").attr('style', 'color:red; visibility:hidden;');
                return true;
            }
        }
        else {
            //Show confirmation dialogue
            if (confirm("Are you sure?\n\nThis task will not be recoverable.")) {
                return true;
            }
            else {
                $("#delete").attr('clicked', 'false');
                return false;
            }
        }
    })

    $("form input[type=image]").click(function () {
        $("input[type=image]", $(this).parents("form")).removeAttr("clicked");
        $(this).attr("clicked", "true");
    });
</script>